﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

using Qianwei.Model;
using Qianwei.Biz;
using Qianwei.Common.Extension;
using Qianwei.Common;

namespace Qianwei.Web.Admins
{
    public partial class EditProductionProcess : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            page_info pageInfo = PageInfoManager.Instance.GetModel("生产工艺");
            if (pageInfo != null)
            {
                hf_contentinit.Value = pageInfo.Page_Content;
            }
        }

        private string CheckInput()
        {
            string strErr = string.Empty;
            if (hfContent.Value.Trim().Length == 0)
            {
                strErr = "请输入内容";
            }
            return strErr;
        }

        private void SaveInfo()
        {
            page_info pageInfo = new page_info();
            pageInfo.Page_Name = "生产工艺";
            pageInfo.Page_Content = hfContent.Value;
            if (PageInfoManager.Instance.Update(pageInfo))
            {
                Util.PageAlert("保存信息成功");
            }
            else
            {
                Util.PageAlert("对不起,保存信息失败,请稍后重试");
            }
            BindData();
        }
        #region Event

        protected void btnSave_Click(object sender, EventArgs e)
        {
            string result = CheckInput();
            if (result.Length > 0)
            {
                Util.PageAlert(result);
            }
            else
            {
                SaveInfo();
            }
        }
        #endregion
    }
}